package com.kim.smartring.net.business;

import com.kim.smartring.db.model.User;
import com.kim.smartring.net.ACommunication;
import com.kim.smartring.net.AEntity;
import com.kim.smartring.net.IReceiverListener;
import com.kim.smartring.net.entity.LoginEntity;
import com.kim.smartring.net.impl.PostCommunication;

import android.content.Context;

public class LoginBusiness {

	public interface LoginCallback {
		void loginSuccess();

		void loginFail();
	}

	/**
	 * 登录
	 * 
	 * @param context
	 * @param account
	 * @param password
	 * @param loginCallback
	 */
	public static void login(Context context, User user,
			final LoginCallback loginCallback) {
		LoginEntity loginEntity = new LoginEntity(context, user,
				new IReceiverListener() {

					@Override
					public void onReceive(AEntity entity) {

					}
				});
		final ACommunication comm = new PostCommunication(loginEntity);
		new Thread(new Runnable() {

			@Override
			public void run() {
				try {
					comm.sendEntity();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}).start();
	}
}
